package Test;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int[] arr1 = {1,2,3,4};
        int[] arr2 = arr1;//数组名代表首元素地址，这一点和C语言相同

        for (int i = 0; i < arr1.length; i++) {
            System.out.print(arr2[i]+" ");
        }
    }


   /* public static void main(String[] args) {

        //java中的数组都是开辟在堆上的，只不过分为静态和动态两种
        int[] arr1 = {1,2,3,4,5};
        int[] arr2 = new int[]{4,5,6,7,8,9};
        int[] arr3 = new int[10];//默认初始化为0，动态内存开辟

        for (int i = 0; i < arr1.length; i++)
        {
            System.out.print(arr1[i]+" ");
        }
        System.out.println();
        for (int i = 0; i < arr2.length; i++)
        {
            System.out.print(arr2[i]+" ");
        }
        System.out.println();
        for (int i = 0; i < arr3.length; i++)
        {
            System.out.print(arr3[i]+" ");
        }

    }*/

    /*public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        System.out.println("亲输入你要创建的数组长度：");
        int n = sc.nextInt();
        System.out.println("请输入数组数据：");

        int[] arr = new int[n];
        for(int i = 0; i < n; i++)
        {
            arr[i] = sc.nextInt();
        }

        //打印
        for (int i = 0; i < arr.length; i++)
        {
            System.out.print(arr[i] + " ");
        }
    }*/
}
